package exercise05_afterclass;

class PrintEvenNum implements Runnable{
    public synchronized void run(){
        for(int i=0;i<100;i++){
            if(i % 2 == 0) {
                System.out.println(Thread.currentThread().getName() + ":" + i);
            }
        }
    }
}
public class Test2 {
    public static void main(String[] args) {
        PrintEvenNum p = new PrintEvenNum();

        Thread t1 = new Thread(p);
        Thread t2 = new Thread(p);
        t1.setName("线程一");
        t1.start();
        t2.setName("线程二");
        t2.start();

    }
}
